package com.redepronik.negosys.rrhh.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * The persistent class for the cargo database table.
 * 
 */
@Entity
@Table(schema = "rrhh", name = "cargo")
@NamedQuery(name = "Cargo.findAll", query = "SELECT c FROM Cargo c")
public class Cargo implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(allocationSize = 1, name = "CARGO_CARGOID_GENERATOR", sequenceName = "RRHH.CARGO_CARGOID_SEQ")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CARGO_CARGOID_GENERATOR")
	@Column(unique = true, nullable = false)
	private Integer cargoid;

	@Column(nullable = false)
	private Boolean activo;

	@Column(nullable = false, length = 100)
	private String nombre;

	@Column(nullable = false)
	private Boolean pordefecto;

	// bi-directional many-to-one association to Empleadocargo
	@OneToMany(orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "cargo")
	private List<Empleadocargo> empleadocargos;

	public Cargo() {
	}

	public Empleadocargo addEmpleadocargo(Empleadocargo empleadocargo) {
		getEmpleadocargos().add(empleadocargo);
		empleadocargo.setCargo(this);

		return empleadocargo;
	}

	public Boolean getActivo() {
		return this.activo;
	}

	public Integer getCargoid() {
		return this.cargoid;
	}

	public List<Empleadocargo> getEmpleadocargos() {
		return this.empleadocargos;
	}

	public String getNombre() {
		return this.nombre;
	}

	public Boolean getPordefecto() {
		return pordefecto;
	}

	public Empleadocargo removeEmpleadocargo(Empleadocargo empleadocargo) {
		getEmpleadocargos().remove(empleadocargo);
		empleadocargo.setCargo(null);

		return empleadocargo;
	}

	public void setActivo(Boolean activo) {
		this.activo = activo;
	}

	public void setCargoid(Integer cargoid) {
		this.cargoid = cargoid;
	}

	public void setEmpleadocargos(List<Empleadocargo> empleadocargos) {
		this.empleadocargos = empleadocargos;
	}

	public void setNombre(String nombre) {
		this.nombre = nombre;
	}

	public void setPordefecto(Boolean pordefecto) {
		this.pordefecto = pordefecto;
	}

}